
package com.punch.common.feign;


import com.punch.common.constant.ServiceNameConstants;
import com.punch.common.dto.course.ClassStartDTO;
import com.punch.common.feign.fallback.FeignOrderServiceFallbackFactory;
import com.punch.common.vo.order.CourseOrderStudentVO;
import com.punch.common.vo.order.SimpleCourseOrderVO;
import com.punch.common.vo.order.StudentCourseClassVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;


/**
 * @author zlt
 */

@FeignClient(name = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = FeignOrderServiceFallbackFactory.class, decode404 = true)
public interface FeignOrderService {

    /**
     * 开班修改订单状态
     *
     * @param classId 课程班级id
     * @return boolean
     */
    @PutMapping(value = "/order/class/{classId}/start-class", produces = "application/json; charset=utf-8")
    Boolean startClass(@PathVariable("classId") Long classId);

    /**
     * 获取开班课程的报名学生id列表
     *
     * @param classId 班级课程id
     * @return 学生id列表
     */
    @GetMapping(value = "/order/course-class-student/{classId}", produces = "application/json; charset=utf-8")
    List<StudentCourseClassVO> getCourseClassOrderStudent(@PathVariable("classId") Long classId);

    /**
     * 某学校某年级下的某个班级报名某个课程情况
     *
     * @param schoolName 学校名称
     * @param gradeYear  年级
     * @param gradeClass 班级
     * @param className  报班名称
     * @return
     */
    @GetMapping(value = "/order/course-class-simple", produces = "application/json; charset=utf-8")
    List<SimpleCourseOrderVO> getSimpleCourseClassOrder(@RequestParam("schoolName") String schoolName,
                                                        @RequestParam("gradeYear") String gradeYear,
                                                        @RequestParam("gradeClass") String gradeClass,
                                                        @RequestParam(value = "className", required = false) String className);

    /**
     * 获取开班课程的报名学生列表
     *
     * @param classId 班级课程id
     * @return 学生列表
     */
    @GetMapping(value = "/order/course-student/{courseId}/{classId}", produces = "application/json; charset=utf-8")
    List<CourseOrderStudentVO> getCourseStudent(@PathVariable("courseId") Long courseId, @PathVariable("classId") Long classId);


    /**
     * 统计开班课程的报名学生
     *
     * @param classId 班级课程id
     * @return 学生列表
     */
    @GetMapping(value = "/order/course-student-count/{courseId}/{classId}", produces = "application/json; charset=utf-8")
    int getCourseStudentCount(@PathVariable("courseId") Long courseId, @PathVariable("classId") Long classId);


    /**
     * 更新该课程下开班的课程订单的已完成课时数
     *
     * @param courseId 课程id
     * @param classId  班级id
     * @return boolean
     */
    @PutMapping(value = "/order/course/{courseId}/{classId}/finish-count", produces = "application/json; charset=utf-8")
    Boolean updateClassFinishCount(@PathVariable("courseId") Long courseId, @PathVariable("classId") Long classId);


    /**
     * 获取学生已报名的订单
     *
     * @param studentId 学生id
     * @return list
     */
    @GetMapping(value = "/order/course/student/{studentId}", produces = "application/json; charset=utf-8")
    List<Long> getStudentCourseOrderId(@PathVariable("studentId") Long studentId);

    /**
     * 学生是否报名该课程
     *
     * @param classId   课程班级id
     * @param studentId 学生id
     * @return boolean
     */
    @GetMapping(value = "/order/course/{classId}/student/{studentId}", produces = "application/json; charset=utf-8")
    boolean isSignUp(@PathVariable("classId") Long classId, @PathVariable("studentId") Long studentId);

    /**
     * 运营修改开班时间
     *
     * @param classId  课程id
     * @param openDate 开班时间
     */
    @PutMapping(value = "/order/course/open-date/{classId}", produces = "application/json; charset=utf-8")
    void feignUpdateCourseOrderOpenDate(@PathVariable("classId") Long classId, @RequestParam("openDate") LocalDate openDate);

    /**
     * 运营修改教师
     *
     * @param classId     课程id
     * @param teacherName 教师名称
     */
    @PutMapping(value = "/order/course/teacher/{classId}", produces = "application/json; charset=utf-8")
    void feignUpdateCourseOrderTeacher(@PathVariable("classId") Long classId, @RequestParam("teacherName") String teacherName);

    /**
     * 运营修改教室
     *
     * @param classId       课程id
     * @param classRoomName 教师
     */
    @PutMapping(value = "/order/course/classroom/{classId}", produces = "application/json; charset=utf-8")
    void feignUpdateCourseOrderClassRoom(@PathVariable("classId") Long classId, @RequestParam("classRoomName") String classRoomName);
}

